\subsection{Transaction}
A transaction is a logical unit of database processing, it includes commands to retrieve, insert, delete and update items in a database.
The properties desired in any transaction are commonly referred to as ACID properties. These properties helps to guarantee that database transactions are processed reliably.

\paragraph{Atomicity: } 
Requires that a transaction is executed to completion. If the transaction fails to complete, then undo the entire transaction.

\paragraph{Consistency: }
Requires that a transaction should take the database from one consistent state to a new consistent state.

\paragraph{Isolation: }
Requires that the execution of a transaction must not be interfered with by any other transaction executing concurrently. 

\paragraph{Durability: }
Requires that when a transaction commits changes to a database, the changes must persist in the database. 

\subsection{Concurrency in databases}
Concurrency in a database allows multiple users to be able access a database at the same time. If concurrent executions from the different users are not controlled, it can result in an inconsistent database. An example of concurrency in relation to our domain is when the same request to search and book flights comes from two different users, these requests can execute concurrently and may access or update flight records at the same time. 

\paragraph{Concurrency problems in relation to our domain:}
Two different users A and B can be presented with the same flight, and depending on the network throughput for each user, user A may be faster to select and book the last available seats on the flight. Resulting in user B not being able to book the flight, even though it was presented as a possible flight for both A and B. \\
This type of situation can occur as while user A is still in the process of booking a flight, the system also presented the same flight to user B as a possible flight, thus resulting in inconsistent data.

\paragraph{Possible Solution}
Some of the main techniques for concurrency control is the use of locks, timestamps, optimistic control etc. Lock-based protocols are the most commonly used methods for concurrency control. It ensures that the changes made to the database are correctly done. However, it can slow down performance when the number of transactions increase because there will be an increase in the number of transactions that have to wait for locks.\\
In this project, we have used optimistic concurrency control. Whenever a user wishes to search and book flights, no checking is done before the flights are presented. If a flight is presented to a user, the user can proceed to book the flight. It is first when the user attempts to save the flight booking that he is informed that the flight is not available.\\
Although optimistic control reduces the time a transaction spends waiting for locks to release, the user might experience collision when an attempt is made to book and save the selected flight. But such collisions are often detected and resolved when they occur.